package com.cloudservice.ccs.biz.impl;

import com.cloudservice.ccs.biz.IRoleManageBiz;
import com.cloudservice.ccs.entity.RoleManage;
import com.cloudservice.ccs.exception.CustomerServiceException;
import com.cloudservice.ccs.exception.RoleManageException;
import com.cloudservice.ccs.mapper.RoleManageMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class RoleManageImpl implements IRoleManageBiz{
    @Autowired
    private RoleManageMapper roleManageMapper;
    @Override
    public void save(RoleManage roleManage) {
        int result = roleManageMapper.save(roleManage);
        if (result == 0) {
            throw new RoleManageException( "Create RoleManage entity error");
        }
    }

    @Override
    public void update(Integer id, RoleManage roleManage) {
        int result = roleManageMapper.update(id, roleManage);
        if (result == 0) {
            throw new RoleManageException("Update RoleManage entity error");
        }
    }

    @Override
    public void partialUpdate(Integer id, Map<String, Object> fields) {
        int result = roleManageMapper.partialUpdate(id, fields);
        if (result == 0) {
            throw new RoleManageException("Partial update RoleManage failed");
        }
    }

    @Override
    public void delete(Integer id) {
        int result = roleManageMapper.delete(id);
        if (result == 0) {
            throw new RoleManageException("Delete RoleManage entity error");
        }
    }

    @Override
    public RoleManage getOne(Integer id) {
        RoleManage roleManage = roleManageMapper.getOne(id);
        if (roleManage == null) {
            throw new RoleManageException("Get RoleManage entity error: no such entity");
        }
        return roleManage;
    }

    @Override
    public List<RoleManage> getAll() {
        return roleManageMapper.getAll();
    }
}
